<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
        <meta name="language" content="sk" /> 
</head>
<body>
<form action="report_3.php" method="GET">
<?php
echo "<h2>Report #3: Výpožičky študentov s vysokým priemerom</h2>";

	function getConnection() {
		$con = mysql_pconnect('147.175.187.53', 'root', 'qwerty123', 65536);
		if (!$con) {
			echo('<h3 style="color: Red;">Cannot connect to MySQL server &nbsp;&nbsp; :\'(</h3>');
			die('Could not connect: ' . mysql_error());
		}
		mysql_query("SET NAMES 'utf8'");
		mysql_select_db("dwh", $con);
		return $con;
	}
	
	$connection = getConnection();	
	$queryString = "SELECT StartDate,EndDate FROM `dwh`.`term`;" ;
	$queryAnswer = mysql_query($queryString,$connection)or die(mysql_error()); 
	echo "Začiatočné obdobie: ";
	echo "<select name='StartDate'>";
	while($row = mysql_fetch_array($queryAnswer) ) {
		echo "<option>".$row[StartDate]."</option>";
	}
	echo "</select><br/>";
	
	$queryString = "SELECT StartDate,EndDate FROM `dwh`.`term`;" ;
	$queryAnswer = mysql_query($queryString,$connection)or die(mysql_error()); 
	echo "Koncové obdobie: ";
	echo "<select name='EndDate'>";
	while($row = mysql_fetch_array($queryAnswer) ) {
		echo "<option>".$row[EndDate]."</option>";
	}
	echo "</select><br/>";
	
	mysql_close($connection);
?>
<span>Študijný priemer: </span><input type="text" name="SummaryRating" value="3.0" /><br/>
<input type="submit" value='Vytvor report'/>
</form>


</body>
</html>